---
name: Flex
group: Primitives
---

# Flex

By default it renders a `<div>` element with `display: flex`.

**You may want to try use a [horizontal Stack](/layout/stack#usage) or [Set](/layout/set) before using Flex.**

## Import

```js
import { Flex } from 'bumbag';
```

## Usage

```jsx-live
<Flex>
  <Box width="50px" height="50px" backgroundColor="primary" />
  <Box width="50px" height="50px" backgroundColor="secondary" />
</Flex>
```

## Alignments

You can apply alignments to your `Flex` using the `alignX` and `alignY` props.

### Horizontal align

```jsx-live
<Flex alignX="center">
  <Box width="50px" height="50px" backgroundColor="primary" />
  <Box width="50px" height="50px" backgroundColor="secondary" />
</Flex>
<Flex alignX="left">
  <Box width="50px" height="50px" backgroundColor="primary" />
  <Box width="50px" height="50px" backgroundColor="secondary" />
</Flex>
<Flex alignX="right">
  <Box width="50px" height="50px" backgroundColor="primary" />
  <Box width="50px" height="50px" backgroundColor="secondary" />
</Flex>
```

### Vertical align

```jsx-live
<Flex alignY="center" height="200px" backgroundColor="white700">
  <Box width="50px" height="50px" backgroundColor="primary" />
  <Box width="50px" height="50px" backgroundColor="secondary" />
</Flex>
<Flex alignY="top" height="200px" backgroundColor="white700">
  <Box width="50px" height="50px" backgroundColor="primary" />
  <Box width="50px" height="50px" backgroundColor="secondary" />
</Flex>
<Flex alignY="bottom" height="200px" backgroundColor="white700">
  <Box width="50px" height="50px" backgroundColor="primary" />
  <Box width="50px" height="50px" backgroundColor="secondary" />
</Flex>
```

## Props

### Flex Props

<!-- Automatically generated -->

<details><Box use="summary" marginBottom="major-2">Inherits <strong><code>Box</code></strong> props</Box>

**<Code fontSize="150" marginRight="major-1">use</Code>**  

<Code isBlock palette="primary" fontSize="150" padding="minor-1" marginBottom="major-2">
{`string
  | (ComponentClass<any, any> & { useProps: any; })
  | (FunctionComponent<any> & { useProps: any; })`}
</Code>

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">className</Code>** <Code fontSize="100" palette="primary">string</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">children</Code>**  

<Code isBlock palette="primary" fontSize="150" padding="minor-1" marginBottom="major-2">
{`string
  | number
  | boolean
  | {}
  | ReactElement<any, string
  | ((props: any) => ReactElement<any, string
  | ...
  | (new (props: any) => Component<any, any, any>)>)
  | (new (props: any) => Component<...>)>
  | ReactNodeArray
  | ReactPortal
  | ((props: BoxProps) => ReactNode)`}
</Code>

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">alignX</Code>** <Code fontSize="100" palette="primary">&#34;right&#34; | &#34;left&#34; | &#34;center&#34;</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">alignY</Code>** <Code fontSize="100" palette="primary">&#34;top&#34; | &#34;bottom&#34; | &#34;center&#34;</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">variant</Code>** <Code fontSize="100" palette="primary">string</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">colorMode</Code>** <Code fontSize="100" palette="primary">string</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">disabled</Code>** <Code fontSize="100" palette="primary">boolean</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">overrides</Code>**  

<Code isBlock palette="primary" fontSize="150" padding="minor-1" marginBottom="major-2">
{`{
  useCSSVariables?: boolean;
  altitudes?: AltitudesThemeConfig;
  borders?: BordersThemeConfig;
  borderRadii?: BorderRadiiThemeConfig;
  ... 96 more ...;
  Template?: TemplateThemeConfig;
}`}
</Code>

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">elementRef</Code>** <Code fontSize="100" palette="primary">((instance: any) =&#62; void) | RefObject&#60;any&#62;</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

**<Code fontSize="150" marginRight="major-1">themeKey</Code>** <Code fontSize="100" palette="primary">string</Code> 

<Divider marginTop="major-2" marginBottom="major-2" />

</details>
            

## Theming

<Theme component={'Flex'} overrides={['Flex.styles.base']}>This is a flex box</Theme>
